//
//  CoreDataUtility.h
//  Ubiqus
//
//  Created by Le Quang Vinh on 12/11/12.
//  Copyright (c) 2012 Le Quang Vinh. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
                            
#define SQLITE_FILE_STORE   @"LeanLocalDatabase.sqlite"
@interface CoreDataUtility : NSObject{
    NSManagedObjectContext* _managedObjectContext;
    NSManagedObjectModel*   _managedObjectModel;
    NSPersistentStoreCoordinator*   _persistentStoreCoordinator;
}
@property (nonatomic, retain)   NSManagedObjectContext* managedObjectContext;
@property (nonatomic, retain)   NSManagedObjectModel*   managedObjectModel;
@property (nonatomic, retain)   NSPersistentStoreCoordinator*   persistentStoreCoordinator;


+ (CoreDataUtility*)defaultCoredataUtility;
- (void)saveContext;
- (void) removeObject: (NSManagedObject*) obj;
- (NSURL*)applicationDocumentDirectory;


/* For retrieve object*/
- (NSMutableArray*)getObjectsForEntity:(NSString*)entityName withSortKey:(NSString*)sortKey andSortAscending:(BOOL)sortAscending andContext:(NSManagedObjectContext*)context;
- (NSMutableArray*)searchObjectsForEntity:(NSString *)entityName withSortKey:(NSString *)sortKey andSortAscending:(BOOL)sortAscending andPredicate:(NSPredicate*)predicate andContext:(NSManagedObjectContext *)context;

/* Create a now object*/
- (NSManagedObject*)createNewObjectForEntityName:(NSString*)entityName;
/* For count object*/

@end
